﻿using System;
using System.Diagnostics;
using Gumini.JulaDB.Provider;
using Gumini.JulaDB.Test.Common;

namespace Gumini.JulaDB.MemoryTest
{
    class Program
    {
        private static JulaDbConnection _connection;

        private static void AddCompany(int id, string name)
        {
            TestUtils.ExecuteValidNonQuery(_connection,
                String.Format("insert into company (Id, Name) values ({0}, '{1}')", id, name));
        }

        static void Main(string[] args)
        {
            _connection = TestUtils.CreateTestDatabase();
            _connection.ExecuteValidNonQuery("create table company (id int, name varchar(100))");
            var w = new Stopwatch();
            w.Start();
            for (int i = 0; ; i++)
            {
                var name = "company" + i;
                AddCompany(i, name);

                if (i % 10000 == 0)
                {
                    var span = w.Elapsed;
                    Console.WriteLine("{0}: added {1}", span, name);
                }
            }
        }
    }
}
